import { api, dataHandler } from 'utils/http';

const listProcess = () => api.get('api/process').then(dataHandler);

const createProcess = (data) => api.post('api/process', data).then(dataHandler);

const inquiryProcess = (data) => api.get('api/process', data).then(dataHandler);

const executionProcess = (data) => api.post('api/process/execution', data).then(dataHandler);

const sendMessage = (data) => api.post('api/process/message', data).then(dataHandler);

const modifyProcess = (data) => api.put('api/process/bpmn', data).then(dataHandler);

const deprecateProcess = (name) => {
  const data = new FormData();
  data.append('name', name);
  data.append('status', true);
  return api.put('api/process/status', data);
};

const sendMessageToAll = (data) => api.post('api/process/messageToManager', data).then(dataHandler);

export {
  listProcess,
  createProcess,
  inquiryProcess,
  executionProcess,
  sendMessage,
  deprecateProcess,
  modifyProcess,
  sendMessageToAll,
};
